<?php @session_start(); ?>

<?php 

//require_once('insertMultiple.php');

$_SESSION['sel'] = $select; 

if($_SESSION['sel'] == "---Select record type---"){

$msg =  "Please select input type from the left menu";
header("location:insertMultiple.php?poll=$msg");
}else{



if ($_SESSION['sel'] == "Food"){

function addItem($IId,$IName,$IPrice){

include "Connect.php";

$query ="insert into food(ID,Name,Price) Values('$IId','$IName','$IPrice')";
$result = mysql_query($query);
if($result){

$msg =  "Data has been successfully entered into the food table";
header("location:insertMultiple.php?poll=$msg");
  }

}

$file = file_get_contents($target_path);
$rows = explode("\n",$file);
foreach($rows as $row){

$mm = rand(5, 15);
$items = explode(",",$row);
 addItem($mm ,@$items[0],@$items[1]);

}

}
if ($_SESSION['sel'] == "Drinks"){
function addItem($IId,$IName,$IPrice){

include "Connect.php";

$query ="insert into drinks(ID,Name,Price) Values('$IId','$IName','$IPrice')";
$result = mysql_query($query);
if($result){

$msg =  "Data has been successfully entered into the drinks table";
header("location:insertMultiple.php?poll=$msg");
  }

}

$file = file_get_contents($target_path);
$rows = explode("\n",$file);
foreach($rows as $row){

$mm = rand(5, 15);
$items = explode(",",$row);
 addItem($mm ,@$items[0],@$items[1]);

}
}

if ($_SESSION['sel'] == "Snacks"){
function addItem($IId,$IName,$IPrice){

include "Connect.php";

$query ="insert into snacks(ID,Name,Price) Values('$IId','$IName','$IPrice')";
$result = mysql_query($query);
if($result){

$msg =  "Data has been successfully entered into the Snacks table";
header("location:insertMultiple.php?poll=$msg");
  }

}

$file = file_get_contents($target_path);
$rows = explode("\n",$file);
foreach($rows as $row){

$mm = rand(5, 15);
$items = explode(",",$row);
 addItem($mm ,@$items[0],@$items[1]);

}
}

if ($_SESSION['sel'] == "Services"){
function addItem($IId,$IName,$IPrice){

include "Connect.php";

$query ="insert into services(ID,Name,Price) Values('$IId','$IName','$IPrice')";
$result = mysql_query($query);
if($result){

$msg =  "Data has been successfully entered into the Services table";
header("location:insertMultiple.php?poll=$msg");
  }

}

$file = file_get_contents($target_path);
$rows = explode("\n",$file);
foreach($rows as $row){

$mm = rand(5, 15);
$items = explode(",",$row);
 addItem($mm ,@$items[0],@$items[1]);

}
}
}



?>